<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"/>
    <title>HELLO，AMAP!</title>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script type="text/javascript">
    window._AMapSecurityConfig = {
        securityJsCode: "b4a922fec0bec6528e909210d2242fe1",
    };
</script>
<script type="text/javascript" src="https://webapi.amap.com/maps?v=2.0&key=c50b37cfeb77a5ce1ce927c96b9d80d4"></script>
<script type="text/javascript">
    var zoom = 16
    //地图初始化应该在地图容器 <div> 已经添加到 DOM 树之后
    var map = new AMap.Map("container", {
        zoom: zoom,
        center: [116.397428, 39.90923], //地图中心点
<!--        mapStyle: "amap://styles/whitesmoke", //设置地图的显示样式-->
<!--        viewMode: "2D", //设置地图模式-->
    });


    function setCurrentLocation(lon, lat) {
        map.setZoomAndCenter(zoom, [lon, lat]) //设置地图的缩放级别和中心点位置

        //创建一个 Marker(标记) 实例：
        var marker = new AMap.Marker({
            position: new AMap.LngLat(lon, lat),
            icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
            map: map,
            offset: new AMap.Pixel(-13, -30), //以 icon 的 [center bottom] 为原点
        });
        //将创建的点标记添加到已有的地图实例：
        map.add(marker);

		map.plugin(['AMap.PlaceSearch'], function() {
			var PlaceSearchOptions = { //设置PlaceSearch属性
				pageSize: 4, //每页结果数,默认10
				pageIndex: 1, //请求页码，默认1
				extensions: "base", //返回信息详略，默认为base（基本信息）
				map:map
			};
			var MSearch = new AMap.PlaceSearch(PlaceSearchOptions); //构造PlaceSearch类
			AMap.Event.addListener(MSearch, "complete", (result)=>{
				//alert(JSON.stringify(result.poiList.pois))
                window.swift.receiveHtmlData(JSON.stringify(result.poiList.pois))

			}); //返回结果
			MSearch.searchNearBy('大厦',[lon, lat]); //关键字查询
		});
    }
</script>